package main

import(
	"fmt"
	"math/rand"
	"sort"
)

type Student struct {
	Name string
	Age int
	Score float64
}

type StudentSlice []Student

func (ss StudentSlice) Len() int {
	return len(ss)
}

func (ss StudentSlice) Less(i, j int) bool {
	return ss[i].Score < ss[j].Score
}

func (ss StudentSlice) Swap(i, j int) {
	ss[i], ss[j] = ss[j], ss[i]
}

func main() {

	var ss StudentSlice
	for i := 0; i < 5; i++ {
		student := Student{
			Name : fmt.Sprintf("学生%d", rand.Intn(100)),
			Age : rand.Intn(100),
			Score : rand.Float64() * 100,
		}
		ss = append(ss, student)
	}
	
	sort.Sort(ss)
	for _, v := range ss {
		fmt.Println(v)
	}

}